package banwood.com.xiongfasy.dialog;

import android.app.Dialog;
import android.content.Context;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.WindowManager;
import android.widget.TextView;

import banwood.com.xiongfasy.R;

/**
 * Created by Administrator on 2017/6/5 0005.
 */

public class LoadingDialog extends Dialog {

    public LoadingDialog(Context context) {
        super(context);
        init();
    }

    public LoadingDialog(Context context, boolean cancelable,
                         OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
        init();
    }


    public LoadingDialog(Context context, int theme) {
        super(context, R.style.MyDialog);
        init();
    }

    private void init() {
        setContentView(R.layout.view_loading_dialog);
        setCancelable(true);
        setCanceledOnTouchOutside(false);
        WindowManager.LayoutParams lp = getWindow().getAttributes();
        lp.gravity = Gravity.CENTER;
        lp.dimAmount = 0.3f;
        getWindow().setAttributes(lp);
    }

    public void setMessage( CharSequence message ) {
        if( !TextUtils.isEmpty(message) ) {
            TextView txt = (TextView)findViewById(R.id.tv_msg);
            txt.setText(message);
        }
    }
}
